package com.lx.pc.service.worder.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lx.pc.domain.entity.worder.WOrderEntity;
import com.lx.pc.domain.vo.worder.WOrderVo;
import com.lx.pc.mybatis.repository.worder.WOrderRepository;
import com.lx.pc.service.AbstractService;
import com.lx.pc.service.worder.IWOrderService;
import com.lx.pc.utils.OmsPage;

@Service("wOrderService")
public class WOrderServiceImpl extends AbstractService<WOrderEntity, WOrderVo, BigInteger, WOrderRepository> implements IWOrderService{

	@Override
	public int findByWOrderCount(WOrderVo orderEntity) {

		return repository.findByWOrderCount(orderEntity);
	}

	@Override
	public OmsPage<WOrderVo> findByWOrder(WOrderVo orderEntity, Integer page, Integer size) {

		OmsPage<WOrderVo> pages = new OmsPage<WOrderVo>();
		pages.setTotal(repository.findByWOrderCount(orderEntity));
		List<WOrderEntity> list = repository.findByWOrder(orderEntity,page = (page - 1) * size,size);
		pages.setResult(etoV(list));
		
		return pages;
	}
	
	@Override
	public WOrderVo findByOrderNum(WOrderVo orderVo) {

		return etoV(repository.findByOrderNum(orderVo));
	}

	@Override
	public String updateStatus(WOrderVo orderVo) {
		repository.update(orderVo);
		return orderVo.getId().toString();
		
	}

	@Override
	public Integer findByReceiptCount(WOrderVo orderVo) {

		return repository.findByReceiptCount(orderVo);
	}

}
